1 ### DispatchProcessMonitor ###
3 ===========================================================================
6 Sample code showing how to: monitor process, do file and network I/O,
7 create and manage timers, and use dispatch_apply
9 ===========================================================================
12 Mac OS X version 10.6 Snow Leopard
14 ===========================================================================
17 Mac OS X version 10.6 Snow Leopard
19 ===========================================================================
22 apply.c - dispatch_apply examples
23 netcat.c - network I/O examples
24 nWide.c - use of dispatch_semaphore to limit number of in-flight blocks
25 proc.c - process monitoring example
26 readFile.c - file I/O examples
27 readFileF.c - file I/O examples without Blocks
28 timers.c - create and manage timers
30 ===========================================================================
35 dispatch-apply takes no arguments. When run it will display some status
36 messages and timing information.
40 Open two terminal windows. In one window run the "server":
42 cat ReadMe.txt | dispatch-netcat -l localhost 5050
44 In the other run the "client":
46 dispatch-netcat localhost 5050
48 Your server will send the contents of ReadMe.txt to the client, the server
49 will close it's connection and exit. The client will display whatever
50 the server sent (the ReadMe.txt file). See the main function in netcat.c
55 dispatch-nWide takes no arguments. When run it will display explanatory
60 dispatch-proc takes no arguments. When run it will display output from
61 some processes it runs, and it will display information from the
62 process lifecycle events dispatch generates.
66 Run dispatch-readFile with a filename as an argument:
68 dispatch-readFile ReadMe.txt
70 It will read the file 10 (or fewer) bytes at a time and display how many
71 bytes dispatch thinks are remaining to read.
75 Exactly the same as dispatch-readFile, but written without the use of Blocks.
79 dispatch-timers takes no arguments, running it display timer ticks for
80 a timer with an initial interval of one second, changing to one half second
81 after the first three events. It will exit after six events.
83 ===========================================================================
84 CHANGES FROM PREVIOUS VERSIONS:
87 - Updated to current libdispatch API, and added samples readFileF.c and
92 ===========================================================================
93 Copyright (C) 2009 Apple Inc. All rights reserved.